﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace XNADota.AnimationModelXFile
{
    class AnimationModelEffect
    {
        private Effect effect;
        private const string CURRENT_TECHNIQUE_NAME = "SkinnedModelTechnique";

        public AnimationModelEffect(Effect effect)
        {
            this.effect = effect;
            


            effect.CurrentTechnique = effect.Techniques[CURRENT_TECHNIQUE_NAME];
            GetEffectParameters();
        }

        private EffectParameter bonesEffectParameters;

        private EffectParameter worldEffectParameter;
        private EffectParameter viewEffectParameter;
        private EffectParameter projectionEffectParameter;

        private EffectParameter numLightEffectParameter;
        private EffectParameter vecLightDirEffectParameter;
        private EffectParameter lightColorEffectParameter;

        private EffectParameter vecEyeEffectParameter;

        private void GetEffectParameters()
        {
            bonesEffectParameters = effect.Parameters["Bones"];

            worldEffectParameter = effect.Parameters["World"];
            viewEffectParameter = effect.Parameters["View"];
            projectionEffectParameter = effect.Parameters["Projection"];

            vecLightDirEffectParameter = effect.Parameters["vecLightDir"];
            lightColorEffectParameter = effect.Parameters["LightColor"];
            numLightEffectParameter = effect.Parameters["NumLights"];

            vecEyeEffectParameter = effect.Parameters["vecEye"];
        }

        #region properties
        public Matrix[] Bones
        {
            set { bonesEffectParameters.SetValue(value); }
        }

        public Matrix World
        {
            set { worldEffectParameter.SetValue(value); }
        }

        public Matrix View
        {
            set { viewEffectParameter.SetValue(value); }
        }

        public Matrix Projection
        {
            set { projectionEffectParameter.SetValue(value); }
        }

        public int NumLight
        {
            set { numLightEffectParameter.SetValue(value); }
        }

        public Vector4[] VecLightDir
        {
            set { vecLightDirEffectParameter.SetValue(value); }
        }

        public Vector4[] LightColor
        {
            set { lightColorEffectParameter.SetValue(value); }
        }

        public Vector4 VecEye
        {
            set { vecEyeEffectParameter.SetValue(value); }
        }
        #endregion
    }
}
